/*
IRC plugin for Miranda IM

Copyright (C) 2003-2005 Jurgen Persson
Copyright (C) 2007 George Hazan

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef _IRCWIN_H_
#define _IRCWIN_H_

#define MIRANDA_VER 0x0700

#if defined( UNICODE ) && !defined( _UNICODE )
	#define _UNICODE 
#endif

// disable a lot of warnings. It should comppile on VS 6 also
#pragma warning( disable : 4076 ) 
#pragma warning( disable : 4786 ) 
#pragma warning( disable : 4996 ) 

#define WIN32_LEAN_AND_MEAN	
#include <tchar.h>
#include <windows.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <objbase.h>
#include <shellapi.h>
#include <malloc.h>
#include <stdio.h>
#include <process.h>
#include <math.h>
#include <winsock.h>
#include <time.h>

#include "newpluginapi.h"
#include "m_history.h"
#include "m_system.h"
#include "m_protocols.h"
#include "m_protomod.h"
#include "m_protosvc.h"
#include "m_clist.h"
#include "m_options.h"
#include "m_database.h"
#include "m_utils.h"
#include "m_skin.h"
#include "m_netlib.h"
#include "m_clui.h"
#include "m_langpack.h"
#include "m_message.h"
#include "m_userinfo.h"
#include "m_addcontact.h"
#include "m_button.h"
#include "m_file.h"
#include "m_ignore.h"
#include "m_chat.h"
#include "m_icolib.h"
#include "m_popup.h"
#include "win2k.h"

#include <string>

#include "gamestat.h"
#include "resource.h"

using std::string;

// contact attributes
#define ADDRESS			"IP"
#define PORT			"Port"
#define GAMETYPE		"Game"
#define NICK			"Nick"
#define MAP				"Map"
#define CLIENTS			"Clients"
#define MAXCLIENTS		"MaxClients"
#define MAPFILTER		"Mapfilter"
#define PLAYERFILTER	"Playerfilter"

#define PROTONAME		"Game Observer"

#define MAX_IP				128
#define MAX_PORT			6
#define MAX_GAME			32
#define MAX_MAP				32
#define MAX_NICK			128
#define MAX_MAPFILTER		1024
#define MAX_PLAYERFILTER	1024

//main.cpp
extern HINSTANCE	g_hInstance;	
extern PLUGININFOEX pluginInfoEx;

//services.cpp
void			HookEvents(void);
void			UnhookEvents(void);
void			CreateServiceFunctions(void);
int				OnJoinServer(WPARAM wParam, LPARAM lParam);

//options.cpp
typedef struct Options {
	WORD	dwUpdateInterval;
	WORD	dwUpdateTimeout;
	WORD	dwSearchTimeout;
	char*	pszMapOnlineSound;
} Options;

typedef struct Game {
	char name[MAX_GAME];
	GS_TYPE type;
	char* cmd;
	char path[MAX_PATH];
} Game;

static Game gameList[] = {
	{"Call of Duty",			GS_TYPE_CALLOFDUTY,		"+connect",		"cod.exe"},
	{"Call of Duty 2",			GS_TYPE_CALLOFDUTY2,	"+connect",		"cod2.exe"},
	{"Jedi Academy",			GS_TYPE_SWJKJA,			"+connect",		"jamp.exe"},
	{"Jedi Outcast",			GS_TYPE_SWJK2,			"+connect",		"jomp.exe"},
	{"Quake",					GS_TYPE_QUAKE1,			"-connect",		"quake.exe"},
	{"Quake 2",					GS_TYPE_QUAKE2,			"+connect",		"quake2.exe"},
	{"Quake 3",					GS_TYPE_QUAKE3,			"+connect",		"quake3.exe"},
	{"Quake 4",					GS_TYPE_QUAKE4,			"+connect",		"quake4.exe"}
};

extern Options	options;
int gameIndex(char* game);
void			LoadOptions(void);
void			SaveOptions(void);
int				InitOptions(WPARAM wParam, LPARAM lParam);

// tools.cpp
extern uintptr_t	timer;
void				Timer_Start(int interval);
void				Timer_Stop();
void				AddIcons();
HICON				LoadIconEx(int iconId);
HANDLE				GetIconHandle(int iconId);
char				*StatusModeToDbSetting(int status, const char *suffix);
int					Filter_CurrentMap(char* current, char* filter);
int					PopUp_Playing(HANDLE hContact, char* contactName, char* message);
int					Notification_Map(HANDLE hContact, char* contactName, GS_SERVERINFO* info);

//clist.cpp
HANDLE	CList_AddContact(const char* ip, const char* port, const char* game, const char* nick);
HANDLE	CList_AddMapFilter(HANDLE hContact, char* mapfilter);
void	CList_SetGlobalStatus(DWORD status, char* message);
int		CList_ForEachContact(void callback(HANDLE));
void	CList_SetInvisible(HANDLE hContact);
void	CList_SetOffline(HANDLE hContact);
void	CList_SetOnline(HANDLE hContact);
void	CList_SetAway(HANDLE hContact);
void	CList_Update(HANDLE hContact);

#endif
